package org.phpgwt.tester.client.tests;

import org.phpgwt.tester.client.remote.PrimitiveTestService;
import org.phpgwt.tester.client.remote.PrimitiveTestServiceAsync;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;

public class PrimitivesTest extends PhpGwtTest {
	private static PrimitiveTestServiceAsync service = GWT.create(PrimitiveTestService.class);

	public static void run() {
		service.getByte(new AsyncCallback<Byte>() {
			public void onSuccess(Byte result) {
				printResult("getByte", result, Byte.MAX_VALUE);
			}

			public void onFailure(Throwable caught) {
				printResult("getByte", caught);
			}
		});

		service.getShort(new AsyncCallback<Short>() {
			public void onSuccess(Short result) {
				printResult("getShort", result, Short.MAX_VALUE);
			}

			public void onFailure(Throwable caught) {
				printResult("getShort", caught);
			}
		});

		service.getInt(new AsyncCallback<Integer>() {
			public void onSuccess(Integer result) {
				printResult("getInt", result, Integer.MAX_VALUE);
			}

			public void onFailure(Throwable caught) {
				printResult("getInt", caught);
			}
		});

		service.getLong(new AsyncCallback<Long>() {
			public void onSuccess(Long result) {
				printResult("getLong", result, Long.MAX_VALUE);
			}

			public void onFailure(Throwable caught) {
				printResult("getLong", caught);
			}
		});

		service.getFloat(new AsyncCallback<Float>() {
			public void onSuccess(Float result) {
				printResult("getFloat", result, 387182.3122f);
			}

			public void onFailure(Throwable caught) {
				printResult("getFloat", caught);
			}
		});

		service.getDouble(new AsyncCallback<Double>() {
			public void onSuccess(Double result) {
				printResult("getDouble", result, 19285672.124213d);
			}

			public void onFailure(Throwable caught) {
				printResult("getDouble", caught);
			}
		});

		service.getBoolean(new AsyncCallback<Boolean>() {
			public void onSuccess(Boolean result) {
				printResult("getBoolean", result, true);
			}

			public void onFailure(Throwable caught) {
				printResult("getBoolean", caught);
			}
		});

		service.getBoolean2(new AsyncCallback<Boolean>() {
			public void onSuccess(Boolean result) {
				printResult("getBoolean2", result, false);
			}

			public void onFailure(Throwable caught) {
				printResult("getBoolean2", caught);
			}
		});

		service.getBoolean3(new AsyncCallback<Boolean>() {
			public void onSuccess(Boolean result) {
				printResult("getBoolean3", result, true);
			}

			public void onFailure(Throwable caught) {
				printResult("getBoolean3", caught);
			}
		});

		service.getChar(new AsyncCallback<Character>() {
			public void onSuccess(Character result) {
				printResult("getChar", result, Character.MAX_VALUE);
			}

			public void onFailure(Throwable caught) {
				printResult("getChar", caught);
			}
		});

		service.getChar2(new AsyncCallback<Character>() {
			public void onSuccess(Character result) {
				printResult("getChar2", result, 'k');
			}

			public void onFailure(Throwable caught) {
				printResult("getChar2", caught);
			}
		});

		service.sendBoolean(true, new AsyncCallback<Boolean>() {
			public void onSuccess(Boolean result) {
				printResult("sendBoolean", result, true);
			}

			public void onFailure(Throwable caught) {
				printResult("sendBoolean", caught);
			}
		});
		
		service.sendByte(Byte.MIN_VALUE, new AsyncCallback<Boolean>() {
			public void onSuccess(Boolean result) {
				printResult("sendByte", result, true);
			}

			public void onFailure(Throwable caught) {
				printResult("sendByte", caught);
			}
		});
		
		service.sendChar(Character.MIN_VALUE, new AsyncCallback<Boolean>() {
			public void onSuccess(Boolean result) {
				printResult("sendChar", result, true);
			}

			public void onFailure(Throwable caught) {
				printResult("sendChar", caught);
			}
		});
		
		service.sendDouble(-6432672.164722d, new AsyncCallback<Boolean>() {
			public void onSuccess(Boolean result) {
				printResult("sendDouble", result, true);
			}

			public void onFailure(Throwable caught) {
				printResult("sendDouble", caught);
			}
		});
		
		service.sendFloat(-53182.324f, new AsyncCallback<Boolean>() {
			public void onSuccess(Boolean result) {
				printResult("sendFloat", result, true);
			}

			public void onFailure(Throwable caught) {
				printResult("sendFloat", caught);
			}
		});
		
		service.sendInt(Integer.MIN_VALUE, new AsyncCallback<Boolean>() {
			public void onSuccess(Boolean result) {
				printResult("sendInteger", result, true);
			}

			public void onFailure(Throwable caught) {
				printResult("sendInteger", caught);
			}
		});
		
		service.sendLong(Long.MIN_VALUE, new AsyncCallback<Boolean>() {
			public void onSuccess(Boolean result) {
				printResult("sendLong", result, true);
			}

			public void onFailure(Throwable caught) {
				printResult("sendLong", caught);
			}
		});
		
		service.sendShort(Short.MIN_VALUE, new AsyncCallback<Boolean>() {
			public void onSuccess(Boolean result) {
				printResult("sendShort", result, true);
			}

			public void onFailure(Throwable caught) {
				printResult("sendShort", caught);
			}
		});
	}
}
